<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <h1>{{msg}}</h1>
    <!-- prevent修饰符可以阻止默认事件，常用于form表单的submit事件 -->
    <button @contextmenu.prevent="">右键</button>
    <br>
    <div @click="fn">
      outerbox
      <!-- stop修饰符可以阻止事件传播 -->
      <div @click.stop="fn1">
        innerbox
      </div>
    </div>
    <br>
    <!-- capture修饰符 把事件传播方式改为捕获 -->
    <div @click.capture="fn">
      outerbox1
      <div @click="fn1">
        innerbox1
      </div>
    </div>
    <br>
    <!-- .self修饰符:当事件要被触发的时候e.target是否是自身,如果是在触发事件 -->
    <div @click.self="fn">
      outerbox2
      <div @click="fn1">
        innerbox2
      </div>
    </div>
    <br>
    <!-- once修饰符 一次性事件 -->
    <div @click.once="fn1">
      innerbox2
    </div>
    <br>
    <input type="text" @keyup.13="ipt" value="13">
    <br>
    <input type="text"@keyup.enter="ipt1" value="enter">
    <br>
    <input type="text" @keyup.space="ipt2" value="space">
    <br>
    <input type="text" @keydown.tab="ipt3" value="tab" >
    <br>
    <input type="text" @keydown.esc="ipt4" value="esc">
  </div>
  <script>
    Vue.config.productionTip = false;
    const vm = new Vue({
      el: "#app",
      data: {
        msg: "hello vue!"
      },
      methods: {
        fn() {
          console.log('外面盒子');
        },
        fn1() {
          console.log('里面盒子');
        },
        ipt() {
          console.log('键码13');
        },
        ipt1() {
          console.log('键码enter');
        },
        ipt2() {
          console.log('space');
        }
        ,
        ipt3() {
          console.log('tab');
        }
        ,
        ipt4() {
          console.log('esc');
        }
      }
    })
  </script>
</body>

</html>